﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="DAGApp.Index" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     <title>上海农副产品质量安全信息查询</title>
    <link rel="stylesheet" href="css/public.css" />
   
    <style>
    	body{
			width: 100%;
			background: url(img/farm_produce_1_background.png) no-repeat;
			background-size: 100% 100%;
			}
		.open1{
			width: 1.5rem;
			text-align: right;
			padding: 0 0.25rem;
			font-weight: 600;
			height: 0.8rem;
			border: 0.05rem solid #FFFFFF;
			line-height: 0.8rem;
			font-weight: 0.6rem;
			border-radius: 0.75rem;
			font-size: 0.4rem;
			background: #E4814D;
			color: #DF5134;
		}
    	.open2{
			width: 0.8rem;
			height: 0.8rem;
			border:0.1rem solid #FFFFFF;
			line-height: 0.8rem;
			text-align: center;
			border-radius: 0.7rem;
			font-size: 0.3rem;
			background: #E9E9E8;
			color: #444444;
			position: relative;
			top: -0.9rem;
			right: -1.1rem;
			right: 0.5rem;
			/*animation:index 0.5s ease-in-out alternate forwards;*/
		}
    	#tf{
    		position: absolute;
    		top: 4rem;
    		left: 1rem;
    	}
    	#origins{
    		position: absolute;
    		top: 4rem;
    		right: 1rem;
    	}
		@-webkit-keyframes index{
			from {left:0px;}
			to {left:1rem;}
		}
		@-webkit-keyframes back{
			from {right:0px;}
			to {right:1rem;}
		}
    </style>
</head>
<body>
   <div id="tf" class="open1">
    	<span>OFF</span>
        <div id="tf2" class="open2">真伪</div>
    </div>
    <div id="origins" class="open1">
    	<span>OFF</span>
        <div id="origins2" class="open2">溯源</div>
    </div>
</body>
    <script type="text/javascript" src="js/jquery-2.1.0.js" ></script>
<script type="text/javascript" src="js/public.js" ></script>
<script>
    $("body").css({ "height": document.documentElement.clientHeight, "width": document.documentElement.clientWidth })
    var a = 0;
    var b = 0;
    $(".open2").on({
        "touchend": function (e) {
            e.preventDefault();
            moveEndX = e.originalEvent.changedTouches[0].pageX,
                moveEndY = e.originalEvent.changedTouches[0].pageY,
                X = moveEndX - startX,
                Y = moveEndY - startY;
            if (Math.abs(X) > Math.abs(Y) && Math.abs(X) > 90) {
                if ($(".open2").index($(this)) == 0) {
                    if (Math.abs(X) > Math.abs(Y) && X > 0) {
                        $(".open2").eq(0).css("right", "-1.1rem").parent().css({ "text-align": "left", "background": "#999999" }).find("span").text("ON")
                        a++
                        
                        //开始查防伪
                        var code = getUrlParam("code");
                       // var code = "908004581004202542";
                        window.location.href = "fw.aspx?code=" + code;
                    } else if (Math.abs(X) > Math.abs(Y) && X < 0) {
                        $(".open2").eq(0).css("right", "0.5rem").parent().css({ "text-align": "right", "background": "##E4814D" }).find("span").text("OFF")
                        a = 0
                        //左滑防伪
                    }
                } else {
                    if (Math.abs(X) > Math.abs(Y) && X > 0) {
                        $(".open2").eq(1).css("right", "-1.1rem").parent().css({ "text-align": "left", "background": "#999999" }).find("span").text("ON")
                        b++
                        //开始查溯源
                        var code = getUrlParam("code");
                        //var code = "403280781606406201";
                        window.location.href = "OriginsCode.aspx?code=" + code;
                    } else if (Math.abs(X) > Math.abs(Y) && X < 0) {
                        $(".open2").eq(1).css("right", "0.5rem").parent().css({ "text-align": "right", "background": "##E4814D" }).find("span").text("OFF")
                        b = 0
                        //左滑溯源
                    }
                }
            } else if (Math.abs(X) >= Math.abs(Y) && Math.abs(X) < 20) {
                if ($(".open2").index($(this)) == 0) {
                    if (a == 0) {
                        $(".open2").eq(0).css("right", "-1.1rem").parent().css({ "text-align": "left", "background": "#999999" }).find("span").text("ON")
                        a++
                        //开始查真伪
                        var code = getUrlParam("code");
                        //var code = "908004581004202542";
                        window.location.href = "fw.aspx?code=" + code;
                    } else {
                        $(".open2").eq(0).css("right", "0.5rem").parent().css({ "text-align": "right", "background": "##E4814D" }).find("span").text("OFF")
                        a = 0
                        //左滑真伪
                    }
                } else {
                    if (b == 0) {
                        $(".open2").eq(1).css("right", "-1.1rem").parent().css({ "text-align": "left", "background": "#999999" }).find("span").text("ON")
                        b++
                        //开始查溯源
                        var code = getUrlParam("code");
                       // var code = "908004581004202542";
                        window.location.href = "OriginsCode.aspx?code=" + code;
                    } else {
                        $(".open2").eq(1).css("right", "0.5rem").parent().css({ "text-align": "right", "background": "##E4814D" }).find("span").text("OFF")
                        b = 0
                        //左滑溯源
                    }
                }
            }
        },
        "touchstart": function (e) {
            e.preventDefault();
            startX = e.originalEvent.changedTouches[0].pageX,
                startY = e.originalEvent.changedTouches[0].pageY;
        }
    })



    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
    }


</script>
</html>
